package com.itheima.wms.common.enums;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public enum WarehouseStatus {
    // 状态 0 停用 1启用

    DISABLE(0, "停用"),
    ENABLE(1, "启用");


    WarehouseStatus(Integer code, String value) {

        this.code = code;
        this.value = value;
    }

    /**
     * 类型编码
     */
    private final Integer code;

    /**
     * 类型值
     */
    private final String value;


    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }


    /**
     * 循环变量
     */
    private static final Map<Integer, WarehouseStatus> LOOKUP = new HashMap<>();

    //静态初始化
    static {

        for (WarehouseStatus statusEnum : EnumSet.allOf(WarehouseStatus.class)) {

            LOOKUP.put(statusEnum.code, statusEnum);
        }
    }

    /**
     * 根据code获取枚举项
     *
     * @param code 值
     * @return 值
     */
    public static WarehouseStatus lookup(Integer code) {
        return LOOKUP.get(code);
    }
}
